package com.SuanFa.jiangdongqi.aaa;


import java.util.Arrays;

class Solution {
    public int findContentChildren(int[] g, int[] s) {
        Arrays.sort(g);    //默认为递增排序
        Arrays.sort(s);
        int ans = 0;
        int i = 0;
        int j = 0;
        while (i<g.length&&j<s.length){
            if (s[j] >= g[i]){
                ans++;
                i++;
                j++;
            }else {
                j++;
            }
        }
        return ans;
    }


    public int maxSubArray(int[] nums) {
        int maxnum = 0,curnum = 0;
        for (int i = 0; i < nums.length; i++) {
            curnum+=nums[i];
            if (maxnum<curnum){
                maxnum=curnum;
            }
            if (curnum<0){
                curnum=0;
            }
        }
        return Math.max(maxnum,0);
    }
}

